<?php

include_once ("slide.php");
include_once ("mysqllib.php");
class slideList {

	private $listSlides;

	//construct from the id of the desired video.
	public function __construct($idVideo) {
		$this -> getAllSlidesById($idVideo);
	}

	
	//Fill the list of slides with the slides of the video with this $idVideo
	public function getAllSlidesById($idVideo) {
		//connect to the database.
		$db = new mysqllib();

		$this -> listSlides = array();

		//Create and send query to get the corresponding slides in the order they will appear
		$query = "SELECT * FROM Slide WHERE idVideo='$idVideo' ORDER BY time ASC";
		$result = mysql_query($query);

		//fetch all the slides
		while ($data = mysql_fetch_array($result)) {
			$slide = new slide();
			$slide -> setSlides($data['idSlide'], $data['idVideo'], $data['time'], $data['type'], $data['filePath']);
			$idSlide = $data['idAnnotation'];
			
			array_push($this -> listSlides ,$slide);
		}

	}

	public function displayAllSlidesPins($duration){
		echo '<div id="pinsSlides">';
		if (!is_null($this -> listSlides)) {
			$id = 1;
			foreach ($this->listSlides as $slide) {

				$slide -> displaySlidePin($duration, $id);
				$id++;
			}
		}

		echo '</div>';
	}
}
?>